







<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">


<script type="text/javascript">
    //$.noConflict();
    $(window).resize(function() {
        $('#grid_weather_log').datagrid('resize');
    });

    function clearweatherlogForm(){
        $('#weatherlogForm').form('clear');
    }

    function clearQueryParamZone(){
        $('#queryForm_Weatherlog').form('clear');
    }

    $(function(){
        $('#grid_weather_log').datagrid({
            //title:'天气',
            width: '100%',
            //height: 400,
            fit: true,
            nowrap: false,
            striped: true,
            collapsible:false,
            url:'/Manage/Weather/log_get_all',
            queryParams:{'facilities_type':1,'facilities_id':$('#pumpstation_id').val(),page:1,rows:20},
            method:'get',
            pageNumber:1,
            pageSize:20,
            idField:'id',
            remoteSort: false,
            columns:[[
                {field:'id',title:'序号',width:60},
                {field:'sta_name',title:'设施名称',width:100},
                {field:'dutyperson',title:'值班人员',width:100},
                {field:'rain_sit',title:'天气情况',width:120},
                {field:'date',title:'上报时间',width:140},
            ]],
            pagination:true,
            rownumbers:true,
            singleSelect:true,
            toolbar: '#grid_weather_log_ToolBar',

            onLoadSuccess: function(data) {
                $(this).datagrid('resize');
            }
        });
        var p = $('#grid_weather_log').datagrid('getPager');
        $(p).pagination({
            onBeforeRefresh:function(){
                //alert('before refresh');
            }
        });

        $('#btnAddWeatherlog').click(function() {
            clearweatherlogForm();
            $("#saveflag_weather_log").val("add");
            $("#facilities_type").val(1);
            $("#facilities_id").val($('#pumpstation_id').val());
            if($("#facilities_id").val() != null && $("#facilities_id").val() !=""){
                $('#weatherlogDlg').dialog({title:'录入天气记录信息',modal:true});
                $('#weatherlogDlg').dialog("open");
//                setFormFocus('#weatherlogForm');
            }
            else{
                $.messager.show({
                    title : '提示',
                    msg : '请选择相应泵站！',
                    showType : 'slide'
                });
            }
        });
        $('#btneditWeatherloglog').click(function() {

            var selected = $('#grid_weather_log').datagrid('getSelected');
            if($('#single').is(":hidden")){
                if (selected) {
                    editWeatherlog(selected.id);
                }
            }else{
                var rows = $('#grid_weather_log').datagrid('getSelections');
                if(rows.length == 1 || rows.length == 0){
                    if (selected) {
                        editWeatherlog(selected.id);
                    }
                    else{
                        $.messager.show({title: "提示",msg: "请选中一条信息，再进行编辑!"});
                    }
                }else{
                    $.messager.alert('提示','当前选择了多条信息，不可以编辑！','error');
                    singleToggle();
                }
            }
        });
        $('#btnDelWeatherlog').click(function() {

            var ids = [];
            var rows = $('#grid_weather_log').datagrid('getSelections');
            for ( var i = 0; i < rows.length; i++) {
                ids.push(rows[i].id);
            }
            if ((ids != null) && (ids.length > 0)) {
                $.messager.confirm('请确认', '你确定要删除吗？', function(r) {
                    if (r) {

                        $('#batchDelForm').ajaxSubmit({
                            url:"/Manage/Weather/log_deleteArray",
                            data:{'ids':ids.join(',')},
                            dataType:'json',
                            success: function(data) {
                                if (data.status==1) {
                                    $('#grid_weather_log').datagrid('reload');
                                    $('#grid_weather_log').datagrid("unselectAll");
                                    $.messager.show({title:'提示',msg:'删除成功！',showType:'slide'});
                                }
                                else $.messager.alert('提示','删除失败！','error');
                            }
                        });

                    }
                });
            }
        });
        $('#btnSearchWeatherlog').click(function() {
            $('#queryParamZone_weather_log').toggle();
            if($('#queryParamZone_weather_log').is(":hidden")){
                clearQueryParamZone();
            }
            $('#grid_weather_log').datagrid("resize");
        });

        $('#btnQueryWeatherlog').click(function() {
            $('#facilities_type').val(1);
            $('#facilities_id').val($('#pumpstation_id').val());
            var obj = $('#queryForm_Weatherlog').serializeJson();
            $('#grid_weather_log').datagrid('load',obj);
        });

        $('#queryParamZone_weather_log').hide();
        $('#single').hide();

        /* WdatePicker({el:'pump_mdate',readOnly:true});
         $dp.hide(); */
    });

    function editWeatherlog(id) {
        if(id!=""){
            $("#saveflag_weather_log").val("update");
        }else{
            clearweatherlogForm();
            $("#saveflag_weather_log").val("add");
            return;
        }
        $.ajax({url:"/Manage/Weather/get_obj_log_json",data:{id:id},dataType:"json",success:function(json, textStatus){
            $('#weatherlogForm').form('load',{
                "id": json.id,
                'facilities_type':1,
                'facilities_id':json.facilities_id,
                "date": json.date,
                "start_time": json.start_time,
                "end_time": json.end_time,
                "rain_sit": json.rain_sit,
                "water_sit": json.water_sit,
                "pump_opensit": json.pump_opensit,
                "pooldep": json.pooldep,
                "dutyperson": json.dutyperson,
            });
            $('#weatherlogDlg').dialog({title:'编辑天气信息',modal:true});
            $('#weatherlogDlg').dialog("open");
            setFormFocus('#weatherlogForm');
        },error:function(XMLHttpRequest, textStatus, errorThrown)
        {
            relogin(XMLHttpRequest, textStatus, errorThrown);
        }});
    }

    function submitweatherlogForm() {
        if ($('#weatherlogForm').form('validate')) {
            var submitflag = $("#saveflag_weather_log").val();
            var url = "";
            if (submitflag === "add")
                url = "/Manage/Weather/log_add";
            if (submitflag === "update")
                url = "/Manage/Weather/log_edit";
            $('#weatherlogForm').ajaxSubmit({
                url:url,
                dataType:'json',
                success: function(data) {
                    if (data.status==1) {
                        if (submitflag === "add") $('#grid_weather_log').datagrid('load');
                        if (submitflag === "update") $('#grid_weather_log').datagrid('reload');
                        $('#weatherlogDlg').dialog("close");
                        $.messager.show({title:'提示',msg:'保存成功！',showType:'slide'});
                    }
                    else $.messager.alert('提示','操作失败！','error');
                }
            });
        }else{
            console.log('no valdate');
        }
    }

    function singleToggle(){
        $('#single').toggle();
        $('#multi').toggle();
        if($('#single').is(":hidden"))
        {
            $('#grid_weather_log').datagrid({singleSelect:true});
            $('input:checkbox','.datagrid-header-check').hide();
        }
        else
        {
            $('#grid_weather_log').datagrid({singleSelect:false});
            $('input:checkbox','.datagrid-header-check').show();
        }
    }
</script>
<table id="grid_weather_log"></table>
<div id="grid_weather_log_ToolBar" style="padding:5px;height:auto">
    <div style="margin-bottom:5px">

<!--        <a id="btnAddWeatherlog" href="#" class="easyui-linkbutton" iconCls="icon-add" plain="true">增加</a>-->
<!---->
<!---->
<!--        <a id="btneditWeatherloglog" href="#" class="easyui-linkbutton" iconCls="icon-edit" plain="true">编辑</a>-->
<!---->
<!--        <a id="btnDelWeatherlog" href="#" class="easyui-linkbutton" iconCls="icon-remove" plain="true">删除</a>-->

        <a id="btnSearchWeatherlog" href="#" class="easyui-linkbutton" iconCls="icon-search" plain="true">搜索</a>

        <a id="btnReload" href="#" class="easyui-linkbutton" iconCls="icon-reload" plain="true" onclick="$('#grid_weather_log').datagrid({url:'/Manage/Weather/log_get_all',queryParams:{'facilities_type':1,'facilities_id':$('#pumpstation_id').val(),page:1,rows:20}})">重载</a>
    </div>
    <div id="queryParamZone_weather_log">
        <form id="queryForm_Weatherlog" method="post" action="">
            <input type="hidden" name="facilities_type" id="facilities_type" value="1"/>
            <input type="hidden" name="facilities_id" id="facilities_id"/>
            <table>
                <tr>
                    <td>雨情记录：</td>
                    <td>
                        <select class="easyui-combobox" name="rain_sit" data-options="prompt:'{:LANG('pls_input')}'" style="width: 80px;">
                            {:weather_status_option()}
                        </select>
                    </td>
                    <td>从：</td>
                    <td><input class="easyui-datebox" name="start" style="width: 150px;"></td>
                    <td>到：</td>
                    <td><input class="easyui-datebox" name="end" style="width: 150px;"></td>
                    <td><span><a id="btnQueryWeatherlog" href="#" class="easyui-linkbutton" iconCls="icon-search">查询</a></span></td>
                    <!--                    <td><a href="#" class="easyui-linkbutton" iconCls="icon-undo" onclick="javascript:$('#queryForm_Weatherlog').form('clear');">重置</a></td>-->
                </tr>
            </table>
        </form>
    </div>
</div>
<div id="weatherlogDlg" class="easyui-dialog" title="" style="width:450px;height:500px;padding:10px" buttons="#dlg-buttons-weather-log" closed="true" resizable="true">
    <form id="weatherlogForm" method="post" action="">
        <input id="saveflag_weather_log" name="saveflag_weather_log" type="hidden" value="add"/>
        <input type="hidden" name="id" />
        <input id="facilities_type" type="hidden" name="facilities_type" value="1"/>
        <input id="facilities_id" type="hidden" name="facilities_id" />
        <table border="0">
            <tr>
                <td align="right">执勤人员：</td>
                <td>
                    <select class="easyui-textbox" name="dutyperson" data-options="prompt:'',required:true" style="width: 140px;">
                        {:weather_status_option()}
                    </select>
                </td>

            </tr>
            <tr>
                <td align="right">天气：</td>
                <td>
                    <select class="easyui-combobox" name="rain_sit" data-options="prompt:'{:LANG('pls_input')}',required:true" style="width: 140px;">
                        {:weather_status_option()}
                    </select>
                </td>

            </tr>
            <tr>
                <td align="right">日期：</td>
                <td>
                    <input class="easyui-datetimebox" type="text" name="date" style="width: 140px;"></input>
                </td>
            </tr>

            <tr>
                <td align="right">开始时间：</td>
                <td>
                    <input class="easyui-datetimebox" type="text" name="start_time" style="width: 140px;"></input>
                </td>

            </tr>
            <tr>
                <td align="right">结束时间：</td>
                <td>
                    <input class=" easyui-datetimebox" type="text" name="end_time" style="width: 140px;"></input>
                </td>
            </tr>
            <tr>
                <td >水情：</td>
                <td >
                    <textarea name="water_sit" style="width: 300px;height: 100px;"></textarea>
                </td>
            </tr>
            <tr>
                <td >泵机开机：</td>
                <td >
                    <textarea name="pump_opensit" style="width: 300px;height: 100px;"></textarea>
                </td>
            </tr>
            <tr>
                <td >积水池水位：</td>
                <td >
                    <textarea name="pooldep" style="width: 300px;height: 100px;"></textarea>
                </td>
            </tr>

        </table>
    </form>
</div>
<div id="dlg-buttons-weather-log" style="text-align: center;">
    <a href="#" class="easyui-linkbutton" iconCls="icon-save" onclick="javascript:submitweatherlogForm();">保存</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-undo" onclick="javascript:editWeatherlog($('#pumpstation_id').val());">重置</a>
</div>
<form id="batchDelForm" method="post">
    <input id="ids" type="hidden" name="ids"/>
</form>